/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2019
 */

package net.dreamlu.db.repo;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import net.dreamlu.db.po.Resource;

/**
 *
 * @author lambert.wang email:lambert.wang(a)crediteyes.com
 * @version 1.0
 * @since 1.0
 */
@Repository
public interface ResourceRepository extends JpaRepository<Resource, java.lang.Integer>, JpaSpecificationExecutor<Resource>{
//	@Query(value ="SELECT r.permissions FROM t_resource r, t_role_resource rr WHERE "
//			+ "r.id = rr.resource_id AND r.status = 1 AND rr.role_id IN (?1)",nativeQuery = true)
//	List<String> findPermissionsByRoleIds(@Param("roleIds") String roleIds);
//	
//	@Query(value = "SELECT  " + 
//			"        DISTINCT s.id,  " + 
//			"        s.name ,  " + 
//			"        s.url ,  " + 
//			"        s.description,  " + 
//			"        s.icon_cls,  " + 
//			"        s.pid,  " + 
//			"        s.seq,  " + 
//			"        s.status,  " + 
//			"        s.open_mode,  " + 
//			"        s.opened,  " + 
//			"        s.resource_type,  " + 
//			"        s.create_time,  " + 
//			"        s.permissions,  " + 
//			"        s.update_time  " + 
//			"        FROM  " + 
//			"        t_role_resource e  " + 
//			"        LEFT JOIN t_resource s ON e.resource_id = s.id  " + 
//			"        WHERE  " + 
//			"        e.role_id in (?1) " + 
//			"        AND s.resource_type = 0  " + 
//			"        AND s.status = 1  " + 
//			"        ORDER BY seq", nativeQuery = true)
//	List<Resource> selectResourceListByRoleIdList(@Param("list") List<Integer> list);
}
